/*
 * @lc app=leetcode.cn id=167 lang=cpp
 *
 * [167] 两数之和 II - 输入有序数组
 */

// @lc code=start
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        vector<int> ans;
        int i = 0, j = numbers.size() - 1;
        for(; j >= i && numbers[i] + numbers[j] > target; j--)
        {
        }
        while(i < j)
        {
            if(numbers[i] + numbers[j] == target)
            {
                ans.push_back(i + 1);
                ans.push_back(j + 1);
                break;
            }
            else
            {
                if(numbers[i] + numbers[j] > target)
                    j--;
                else
                    i++;
                
            }
            
        }
        return ans;
    }
};
// @lc code=end

